package com.lovo.lesson;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashSet;
import java.util.List;

public class Test02 {
    public static void main(String[] args) {
        List<Student> list = new ArrayList();
        list.add(new Student("小强",24,"男"));
        list.add(new Student("阿三",23,"男"));
        list.add(new Student("小刚",27,"男"));
        list.add(new Student("小马",21,"男"));
        list.add(new Student("小苟",19,"男"));

//        list.sort(new MyComparator());

        list.sort(new Comparator<Student>() {
            @Override
            public int compare(Student s1, Student s2) {
                return s1.getAge() - s2.getAge();
            }
        });
        for(Student stu : list){
            System.out.println(stu);
        }

        HashSet hashSet = new HashSet();
        hashSet.addAll(list);
        System.out.println(hashSet);
    }
}
